#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int fun(char a[10], char b[10])
{
	char tmp[256] = { 0 };
	strcpy(tmp, a);
	strcat(tmp, a);
	return strstr(tmp, b) != NULL;
}
int main()
{
	char a[10], b[10];
	gets(a);
	gets(b);
	int num = fun(a, b);
	if (num)
	{
		printf("YES\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}